import 'package:animal/constant/color.dart';
import 'package:animal/constant/font.dart';
import 'package:animal/ui/login/controller/set_pwd_controller.dart';
import 'package:animal/utils/screen_util.dart';
import 'package:animal/widgets/appbar_widget.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:getwidget/getwidget.dart';

///设置密码
class SetPwdPage extends StatelessWidget {
  const SetPwdPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final controller = Get.put(SetPwdController());
    return Scaffold(
      backgroundColor: KColorConstant.white,
      appBar: AppBarWidget.defaultAppBar(title: const Text("设置密码"), elevation: 0, backgroundColor: KColorConstant.white),
      body: Column(
        children: [
          Container(
            margin: EdgeInsets.only(top: ScreenUtil().L(50), bottom: ScreenUtil().L(30), left: ScreenUtil().L(30), right: ScreenUtil().L(30)),
            child: Obx(() {
              return TextField(
                controller: controller.pwdController,
                maxLength: 20,
                obscureText: controller.obscure.value,
                cursorRadius: Radius.circular(ScreenUtil().L(2)),
                keyboardType: TextInputType.visiblePassword,
                focusNode: controller.userFocusNode,
                decoration: InputDecoration(
                    hintText: "请输入密码",
                    hintStyle: KFontConstant.myTextStyle(size: 15, color: const Color(0XFFBFC4CC)),
                    border: OutlineInputBorder(
                        borderRadius: BorderRadius.circular(ScreenUtil().L(5)),
                        borderSide: BorderSide(width: ScreenUtil().L(1), color: KColorConstant.lineE2E5E8)),
                    helperText: "密码由6-20位英文字母、数字或符号组成",
                    helperStyle: KFontConstant.myTextStyle(size: 15, color: KColorConstant.black999999),
                    suffixIcon: InkWell(
                        onTap: () => controller.obscure.value = !controller.obscure.value,
                        highlightColor: const Color(0x00FFFFFF),
                        hoverColor: const Color(0x00FFFFFF),
                        child: Obx(() {
                          return GFIconButton(
                            type: GFButtonType.transparent,
                            icon: controller.obscure.value ? const Icon(Icons.visibility_off) : const Icon(Icons.visibility),
                            onPressed: () => controller.obscure.value = !controller.obscure.value,
                          );
                        })),
                    counterText: ""),
              );
            }),
          ),
          CupertinoButton(
              child: Text("确认", style: KFontConstant.myTextStyle(size: 15, color: KColorConstant.white)),
              onPressed: () => controller.setPwd(),
              color: KColorConstant.btnColor19ACE5)
        ],
      ),
    );
  }
}
